<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Battery Service</title>
<link href="tabs.css" rel="stylesheet" type="text/css" />
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="alias.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="alias.js"></script>

<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>


<script type="text/javascript">
  jQuery(document).ready(function () {
    if(gref){ // Number all _img and _table classes
      gref();
    }
  });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->

<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">nRF51822 BLE SDK
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('group__ble__sdk__srv__bas.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#enum-members">Enumerations</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Battery Service</div>  </div>
<div class="ingroups"><a class="el" href="group__ble__sdk__srv.html">Bluetooth Services</a></div></div>
<div class="contents">

<p>Battery Service module.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structble__bas__evt__t.html">ble_bas_evt_t</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Battery Service event.  <a href="structble__bas__evt__t.html#details">More...</a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structble__bas__init__t.html">ble_bas_init_t</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Battery Service init structure. This contains all options and data needed for initialization of the service.  <a href="structble__bas__init__t.html#details">More...</a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structble__bas__s.html">ble_bas_s</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Battery Service structure. This contains various status information for the service.  <a href="structble__bas__s.html#details">More...</a><br/></td></tr>
<tr><td colspan="2"><h2><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gaea81f98230816bcfcbfd6ccbb4db3999"></a><!-- doxytag: member="ble_sdk_srv_bas::ble_bas_t" ref="gaea81f98230816bcfcbfd6ccbb4db3999" args="" -->
typedef struct <a class="el" href="structble__bas__s.html">ble_bas_s</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ble__sdk__srv__bas.html#gaea81f98230816bcfcbfd6ccbb4db3999">ble_bas_t</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Battery Service structure. This contains various status information for the service. <br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga07fd95f8afa679110161bb8391496abd"></a><!-- doxytag: member="ble_sdk_srv_bas::ble_bas_evt_handler_t" ref="ga07fd95f8afa679110161bb8391496abd" args=")(ble_bas_t *p_bas, ble_bas_evt_t *p_evt)" -->
typedef void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ble__sdk__srv__bas.html#ga07fd95f8afa679110161bb8391496abd">ble_bas_evt_handler_t</a> )(<a class="el" href="group__ble__sdk__srv__bas.html#gaea81f98230816bcfcbfd6ccbb4db3999">ble_bas_t</a> *p_bas, <a class="el" href="structble__bas__evt__t.html">ble_bas_evt_t</a> *p_evt)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Battery Service event handler type. <br/></td></tr>
<tr><td colspan="2"><h2><a name="enum-members"></a>
Enumerations</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ble__sdk__srv__bas.html#gab63b7f474ce48636cd355f6b75ea1ca9">ble_bas_evt_type_t</a> { <a class="el" href="group__ble__sdk__srv__bas.html#ggab63b7f474ce48636cd355f6b75ea1ca9a657f8681ada82fd2990d5458442ed85a">BLE_BAS_EVT_NOTIFICATION_ENABLED</a>, 
<a class="el" href="group__ble__sdk__srv__bas.html#ggab63b7f474ce48636cd355f6b75ea1ca9afcba4bddb1a583374bb27d3f3ed5b8d1">BLE_BAS_EVT_NOTIFICATION_DISABLED</a>
 }</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Battery Service event type.  <a href="group__ble__sdk__srv__bas.html#gab63b7f474ce48636cd355f6b75ea1ca9">More...</a><br/></td></tr>
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ble__sdk__srv__bas.html#gacb8ac9205dcec39e216575c76261c807">ble_bas_init</a> (<a class="el" href="group__ble__sdk__srv__bas.html#gaea81f98230816bcfcbfd6ccbb4db3999">ble_bas_t</a> *p_bas, const <a class="el" href="structble__bas__init__t.html">ble_bas_init_t</a> *p_bas_init)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize the Battery Service.  <a href="#gacb8ac9205dcec39e216575c76261c807"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ble__sdk__srv__bas.html#ga01b70d77540660d7e312121d9f1d3b3a">ble_bas_on_ble_evt</a> (<a class="el" href="group__ble__sdk__srv__bas.html#gaea81f98230816bcfcbfd6ccbb4db3999">ble_bas_t</a> *p_bas, <a class="el" href="structble__evt__t.html">ble_evt_t</a> *p_ble_evt)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Battery Service BLE stack event handler.  <a href="#ga01b70d77540660d7e312121d9f1d3b3a"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ble__sdk__srv__bas.html#ga58d8f4336cce49ea5b3a2f8997bfe00e">ble_bas_battery_level_update</a> (<a class="el" href="group__ble__sdk__srv__bas.html#gaea81f98230816bcfcbfd6ccbb4db3999">ble_bas_t</a> *p_bas, uint8_t battery_level)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Update battery level.  <a href="#ga58d8f4336cce49ea5b3a2f8997bfe00e"></a><br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<p>Battery Service module. </p>
<p>This module implements the Battery Service with the Battery Level characteristic. During initialization it adds the Battery Service and Battery Level characteristic to the BLE stack database. Optionally it can also add a Report Reference descriptor to the Battery Level characteristic (used when including the Battery Service in the HID service).</p>
<p>If specified, the module will support notification of the Battery Level characteristic through the <a class="el" href="group__ble__sdk__srv__bas.html#ga58d8f4336cce49ea5b3a2f8997bfe00e" title="Update battery level.">ble_bas_battery_level_update()</a> function. If an event handler is supplied by the application, the Battery Service will generate Battery Service events to the application.</p>
<dl class="note"><dt><b>Note:</b></dt><dd>The application must propagate BLE stack events to the Battery Service module by calling <a class="el" href="group__ble__sdk__srv__bas.html#ga01b70d77540660d7e312121d9f1d3b3a" title="Battery Service BLE stack event handler.">ble_bas_on_ble_evt()</a> from the from the <a class="el" href="group__ble__stack__handler.html">BLE Stack Event Handler</a> callback. </dd></dl>
<hr/><h2>Enumeration Type Documentation</h2>
<a class="anchor" id="gab63b7f474ce48636cd355f6b75ea1ca9"></a><!-- doxytag: member="ble_bas.h::ble_bas_evt_type_t" ref="gab63b7f474ce48636cd355f6b75ea1ca9" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="group__ble__sdk__srv__bas.html#gab63b7f474ce48636cd355f6b75ea1ca9">ble_bas_evt_type_t</a></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Battery Service event type. </p>
<dl><dt><b>Enumerator: </b></dt><dd><table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><em><a class="anchor" id="ggab63b7f474ce48636cd355f6b75ea1ca9a657f8681ada82fd2990d5458442ed85a"></a><!-- doxytag: member="BLE_BAS_EVT_NOTIFICATION_ENABLED" ref="ggab63b7f474ce48636cd355f6b75ea1ca9a657f8681ada82fd2990d5458442ed85a" args="" -->BLE_BAS_EVT_NOTIFICATION_ENABLED</em>&nbsp;</td><td>
<p>Battery value notification enabled event. </p>
</td></tr>
<tr><td valign="top"><em><a class="anchor" id="ggab63b7f474ce48636cd355f6b75ea1ca9afcba4bddb1a583374bb27d3f3ed5b8d1"></a><!-- doxytag: member="BLE_BAS_EVT_NOTIFICATION_DISABLED" ref="ggab63b7f474ce48636cd355f6b75ea1ca9afcba4bddb1a583374bb27d3f3ed5b8d1" args="" -->BLE_BAS_EVT_NOTIFICATION_DISABLED</em>&nbsp;</td><td>
<p>Battery value notification disabled event. </p>
</td></tr>
</table>
</dd>
</dl>

<p>Definition at line <a class="el" href="ble__bas_8h_source.html#l00045">45</a> of file <a class="el" href="ble__bas_8h_source.html">ble_bas.h</a>.</p>

</div>
</div>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="gacb8ac9205dcec39e216575c76261c807"></a><!-- doxytag: member="ble_bas.h::ble_bas_init" ref="gacb8ac9205dcec39e216575c76261c807" args="(ble_bas_t *p_bas, const ble_bas_init_t *p_bas_init)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint32_t ble_bas_init </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__ble__sdk__srv__bas.html#gaea81f98230816bcfcbfd6ccbb4db3999">ble_bas_t</a> *&#160;</td>
          <td class="paramname"><em>p_bas</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="structble__bas__init__t.html">ble_bas_init_t</a> *&#160;</td>
          <td class="paramname"><em>p_bas_init</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Initialize the Battery Service. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[out]</td><td class="paramname">p_bas</td><td>Battery Service structure. This structure will have to be supplied by the application. It will be initialized by this function, and will later be used to identify this particular service instance. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">p_bas_init</td><td>Information needed to initialize the service. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>NRF_SUCCESS on successful initialization of service, otherwise an error code. </dd></dl>

<p>Definition at line <a class="el" href="ble__bas_8c_source.html#l00196">196</a> of file <a class="el" href="ble__bas_8c_source.html">ble_bas.c</a>.</p>

</div>
</div>
<a class="anchor" id="ga01b70d77540660d7e312121d9f1d3b3a"></a><!-- doxytag: member="ble_bas.h::ble_bas_on_ble_evt" ref="ga01b70d77540660d7e312121d9f1d3b3a" args="(ble_bas_t *p_bas, ble_evt_t *p_ble_evt)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void ble_bas_on_ble_evt </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__ble__sdk__srv__bas.html#gaea81f98230816bcfcbfd6ccbb4db3999">ble_bas_t</a> *&#160;</td>
          <td class="paramname"><em>p_bas</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structble__evt__t.html">ble_evt_t</a> *&#160;</td>
          <td class="paramname"><em>p_ble_evt</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Battery Service BLE stack event handler. </p>
<p>Handles all events from the BLE stack of interest to the Battery Service.</p>
<dl class="note"><dt><b>Note:</b></dt><dd>For the requirements in the BAS specification to be fulfilled, <a class="el" href="group__ble__sdk__srv__bas.html#ga58d8f4336cce49ea5b3a2f8997bfe00e" title="Update battery level.">ble_bas_battery_level_update()</a> must be called upon reconnection if the battery level has changed while the service has been disconnected from a bonded client.</dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">p_bas</td><td>Battery Service structure. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">p_ble_evt</td><td>Event received from the BLE stack. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="ble__bas_8c_source.html#l00070">70</a> of file <a class="el" href="ble__bas_8c_source.html">ble_bas.c</a>.</p>

</div>
</div>
<a class="anchor" id="ga58d8f4336cce49ea5b3a2f8997bfe00e"></a><!-- doxytag: member="ble_bas.h::ble_bas_battery_level_update" ref="ga58d8f4336cce49ea5b3a2f8997bfe00e" args="(ble_bas_t *p_bas, uint8_t battery_level)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint32_t ble_bas_battery_level_update </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__ble__sdk__srv__bas.html#gaea81f98230816bcfcbfd6ccbb4db3999">ble_bas_t</a> *&#160;</td>
          <td class="paramname"><em>p_bas</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>battery_level</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Update battery level. </p>
<p>The application calls this function after having performed a battery measurement. If notification has been enabled, the battery level characteristic is sent to the client.</p>
<dl class="note"><dt><b>Note:</b></dt><dd>For the requirements in the BAS specification to be fulfilled, this function must be called upon reconnection if the battery level has changed while the service has been disconnected from a bonded client.</dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">p_bas</td><td>Battery Service structure. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">battery_level</td><td>New battery measurement value (in percent of full capacity). </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>NRF_SUCCESS on success, otherwise an error code. </dd></dl>

<p>Definition at line <a class="el" href="ble__bas_8c_source.html#l00221">221</a> of file <a class="el" href="ble__bas_8c_source.html">ble_bas.c</a>.</p>

</div>
</div>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>


    <li class="footer">
      Copyright &copy 2006-2011 <a href="http://www.nordicsemi.no" style="text-decoration:none">Nordic Semiconductor</a>.
      All Rights Reserved.
      <a href="disclaimer.html">Disclaimer</a>
    </li>
   </ul>
 </div>


</body>
</html>
